import {reqCategoryList,reqGetBannerList,reqGetFloorList} from '@/api'
const state = {
    categoryList: [],
    bannerList:[],
    floorList:[],
};
const actions = {
  async getCategory({commit}){
        // 请求数据 reqCategoryList()
        let result = await reqCategoryList();
        // 判断网络是否请求成功
        if(result.code == 200){
            // 向mutations传(result.data)请求回来的数据
            commit('GETCATEGORY',result.data)
        }
    },
    async getBannerList({commit}){
        // 请求数据 reqCategoryList()
        let result = await reqGetBannerList();
        // 判断网络是否请求成功
        if(result.code == 200){
            // 向mutations传(result.data)请求回来的数据
            commit('GETBANNERLIST',result.data)
        }
    },
    
    async getFloorList({commit}){
        // 请求数据 reqCategoryList()
        let result = await reqGetFloorList();
        // 判断网络是否请求成功
        if(result.code == 200){
            // 向mutations传(result.data)请求回来的数据
            commit('GETFLOORLIST',result.data)
        }
    },
};
const mutations = {
    GETCATEGORY(state,category){
        state.categoryList = category
    },
    GETBANNERLIST(state,bannerList){
        state.bannerList = bannerList
    },
    GETFLOORLIST(state,floorList){
        state.floorList = floorList
    },
};
const getter = {};
export default {
    state,
    actions,
    mutations,
    getter
}